package cn.xuewenbao.edu.controller;


import cn.xuewenbao.edu.service.FavoriteService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.jeecg.common.api.vo.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * <p>
 * 收藏表 前端控制器
 * </p>
 *
 * @author mafayu
 * @since 2021-04-21
 */
@RestController
@RequestMapping("/edu/favorite")
@Api(tags = "收藏表")
public class FavoriteController {

    @Autowired
    private FavoriteService favoriteService;

    //点赞表-用户点赞内容
    @ApiOperation("收藏内容")
    @PostMapping("favoriteContent")
    public Result<?> favoriteContent(@RequestBody Map<String, String> map) {
        String userId = map.get("userId");
        String columnType = map.get("columnType");
        String contentId = map.get("contentId");
        Result<?> result = favoriteService.favoriteContent(userId, contentId, columnType);
        return result;
    }

    @ApiOperation("取消收藏内容")
    @PostMapping("unfavoriteContent")
    public Result<?> unfavoriteContent(@RequestBody Map<String, String> map) {
        String userId = map.get("userId");
        String columnType = map.get("columnType");
        String contentId = map.get("contentId");
        Result<?> result = favoriteService.unfavoriteContent(contentId, userId, columnType);
        return result;
    }

    //点赞表-获取我的点赞列表
    @ApiOperation("获取我的收藏列表")
    @PostMapping("favoriteList")
    public Result<?> likeList(@RequestBody Map<String, String> map) {
        String userId = map.get("userId");
        String columnType = map.get("columnType");
        Result<?> result = favoriteService.favoriteList(userId, columnType);
        return result;
    }

}

